﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DotNet.WinUI.Basic
{
    public partial class FrmLayout : Form
    {
        public FrmLayout()
        {
            InitializeComponent();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string _Sex = "";
            if (radMale.Checked == true)
            {
                _Sex = radMale.Text;
            }
            else if (radFemale.Checked == true)
            {
                _Sex = radFemale.Text;
            }
            string _Interest= "";
            for(int i = 0; i<= chkInterest.Items.Count -1 ; i++)
            {
                if(chkInterest.GetItemChecked(i))
                {
                    _Interest += chkInterest.GetItemText(chkInterest.Items[i]) + " ";
                }
            }

            string _Info = string.Format("姓名：{0}，出生日期：{1}，民族：{2}，手机号码：{3}，电子邮件：{4}，性别:{5}，家庭住址：{6}，兴趣爱好：{7}",
                txtName.Text,
                dtBirthday.Text,
                cmbNation.Text,
                txtPhone.Text,
                txtEmail.Text,
                _Sex,
                txtAddress.Text,
                _Interest);
            MessageBox.Show(_Info, "消息框标题", MessageBoxButtons.OK, MessageBoxIcon.Information).ToString();
        }

        private void cheSelectAll_CheckedChanged(object sender, EventArgs e)
        {
            if (cheSelectAll.Checked)
            {
                for (int j = 0; j < chkInterest.Items.Count; j++)
                {
                    chkInterest.SetItemChecked(j, true);
                }
            }
            else
            {
                for (int j = 0; j < chkInterest.Items.Count; j++)
                {
                    chkInterest.SetItemChecked(j, false);
                }
            }
        }

        private void FrmMain_Load(object sender, EventArgs e)
        {
            dtBirthday.Text = DateTime.Now.ToString("yyyy-MM-dd");
        }
    }
}
